package com.example.demo.entity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

/**
 * @author zjj
 * @date 2021-04-15
 * 用户信息
 */
@Entity
@Table(name = "t_user")
@Getter
@Setter
public class User implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NotNull(groups = Update.class)
    private Long id;

//    针对字符串进行判空处理，是字符串去除空格.trim()之后的判断
    @NotBlank(message = "用户名不能为空")
    @Column(name = "user_name",unique = true)
    private String userName;

    @NotBlank
    private String password;

    private int sex;
    @Email
    private String email;

    @Pattern(regexp = "1[3|4|5|6|7|8|9][0-9]{9}")
    private String phone;

    @NotNull
    private Boolean status;

    @Column(name = "create_id")
    private Long createId;

    @Column(name = "create_time")
    @CreationTimestamp
    private Timestamp createTime;

    @Column(name = "update_id")
    private Long updateId;

    @Column(name = "update_time")
    @CreationTimestamp
    private Timestamp updateTime;

    @Column(name = "role_id")
    private Long roleId;

    @Column(name = "dept_id")
    private Long deptId;

    @Column(name = "isdel")
    private Boolean isdel;

    @Column(name = "last_pwd_reset_time")
    private Date lastPwdResetTime;

    @Column
    private String remark;

    public @interface Update{}





}
